package com.github.shiqiyue.learn.guava;

import com.google.common.base.CharMatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
 * 描述
 * @author wenyao.wu
 * @date 2018/7/3
 */
public class CharMatchTest {

    private static final Logger logger = LoggerFactory.getLogger(CharMatchTest.class);

    public static void main(String[] args) {
        // only the digits
        logger.info(CharMatcher.DIGIT.retainFrom("mahesh123"));
        logger.info(CharMatcher.WHITESPACE.trimAndCollapseFrom("     Mahesh     Parashar ", ' '));
        // trim whitespace at ends, and replace/collapse whitespace into single spaces
        // star out all digits
        logger.info(CharMatcher.JAVA_DIGIT.replaceFrom("mahesh123", "*"));
        logger.info(CharMatcher.JAVA_DIGIT.or(CharMatcher.JAVA_LOWER_CASE).retainFrom("mahesh123"));
        // eliminate all characters that aren't digits or lowercase
    }
}
